package config

import (
	"github.com/tal-tech/go-zero/rest/httpx"
	"karnin-zero-admin/common/response"
	"karnin-zero-admin/service/sys/api/internal/logic/config"
	"karnin-zero-admin/service/sys/api/internal/svc"
	"karnin-zero-admin/service/sys/api/internal/types"
	"net/http"
)

func ConfigCreateHandler(ctx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.ConfigCreateRequest
		if err := httpx.Parse(r, &req); err != nil {
			httpx.Error(w, err)
			return
		}

		l := config.NewConfigCreateLogic(r.Context(), ctx)
		resp, err := l.ConfigCreate(req)
		response.Response(w, resp, err) //②

	}
}
